]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/entry: Unset key focus when made unreactive
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 29 Mar 2020 17:36:12 +0000 (19:36 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 29 Mar 2020 20:12:57 +0000 (22:12 +0200)
It seems reasonable that an entry shouldn't allow entering text when not
reactive. The same could be achieved by changing the text's :editable
property, however that will disable scrolling if the text doesn't fit,
which may result in an unwanted size change.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423

src/st/st-entry.c

index 2be524bb36cb12908b1402fc86e3f6735c4a6803..9391ffb804e51f13a5f7dac3430a959dee69251b 100644 (file)
@@ -513,6 +513,26 @@ st_entry_allocate (ClutterActor          *actor,
   clutter_actor_allocate (priv->entry, &child_box, flags);
 }
 
+static void
+clutter_text_reactive_changed_cb (ClutterActor *text,
+                                  GParamSpec   *pspec,
+                                  gpointer      user_data)
+{
+  ClutterActor *stage;
+
+  if (clutter_actor_get_reactive (text))
+    return;
+
+  if (!clutter_actor_has_key_focus (text))
+    return;
+
+  stage = clutter_actor_get_stage (text);
+  if (stage == NULL)
+    return;
+
+  clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL);
+}
+
 static void
 clutter_text_focus_in_cb (ClutterText  *text,
                           ClutterActor *actor)
@@ -981,6 +1001,9 @@ st_entry_init (StEntry *entry)
                           priv->entry, "reactive",
                           G_BINDING_DEFAULT);
 
+  g_signal_connect(priv->entry, "notify::reactive",
+                   G_CALLBACK (clutter_text_reactive_changed_cb), entry);
+
   g_signal_connect (priv->entry, "key-focus-in",
                     G_CALLBACK (clutter_text_focus_in_cb), entry);